﻿
@{
    ViewBag.Title = "Grid";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using CSM_SQL;
@using System.Configuration;
@model List<ShowGoods>

<h1 style="float:right">
    @{string title = "";
        var type = Model.First().type;
        switch (Model.First().type)
        {

            case 0:
                title = "零食&饮料";
                break;
            case 1: title = "电子&数码"; break;
            case 2: title = "厨卫&家居"; break;
            case 3: title = "水果&干果"; break;
            default: title = "其他"; break;
        }
    }
    @title
</h1>
<section class="grid-shop">
    <div class="container">
        <div class="row">
            <div class="col-sm-12 col-md-12">
                <div class="grid-spr">
                    <div class="col-sm-6 col-md-6">
                        <a href=@Url.Action("Grid") class="grid-view-icon"><i class="fa fa-th-large" aria-hidden="true"></i></a>
                        <a href=@Url.Action("List") class="list-view-icon"><i class="fa fa-list" aria-hidden="true"></i></a>

                    </div>
                    <div class="col-sm-6 col-md-6 text-right"> <strong></strong> </div>
                </div>

                @foreach (var m in Model)
                {

                    var path = ConfigurationManager.AppSettings["path"].ToString() + m.img;
                    <div class="col-xs-12 col-sm-6 col-md-4">
                        <!-- .pro-text -->
                        <div class=" pro-text text-center">
                            <!-- .pro-img -->
                            <div class="pro-img">
                                @if (m.grade >= 5)
                                {
                                    <sup class="sale-tag">sale!</sup>
                                }
                                <img src=@path alt="2">
                                <!-- .hover-icon -->
                                <div class="hover-icon"> <a href="#"><span class="icon icon-Heart"></span>评分：@m.grade</a> </div>
                                <!-- /.hover-icon -->
                            </div>
                            <!-- /.pro-img -->
                            <div class=" pro-text-outer">
                                <h3>@m.name</h3>


                                <ul class="list-inline">
                                    @{var i = 0; }
                                    @for (i = 0; i < m.grade; i++)
                                    {
                                        <li style="color:gold"><i class="fa fa-star" aria-hidden="true"></i></li>
                                    }

                                    @for (; i < 5; i++)
                                    {
                                        <li><i class="fa fa-star" aria-hidden="true"></i></li>
                                    }


                                </ul>

                                <p style="overflow:auto"> @m.detail </p>

                                <p class="wk-price">￥@m.price </p> <a href="javascript:void(0)" onclick="pick(@m.id)"  class="add-btn">加入购物车</a>
                            </div>
                        </div>
                        <!-- /.pro-text -->
                    </div>
                }

                <div class="col-xs-12">
                    <div class="grid-spr pag">
                        <!-- .pagetions -->
                        <div class="col-xs-12 col-sm-6 col-md-6 text-left">
                            <ul class="pagination">
                                @if (ViewBag.page > 1)
                                {
                                    <li><a href=@Url.Action("List",new { id = type,page = ViewBag.page - 1 })>&laquo;</a></li>
                                }
                                @for (int i = 1; i <= ViewBag.pages; i++)
                                {
                                    if (ViewBag.page == i)
                                    {
                                        <li class="active"><a href="javascript:void(0)">@i</a></li>
                                    }
                                    else
                                    {
                                        <li><a href=@Url.Action("List",new { id = type,page = i })>@i</a></li>
                                    }
                                }
                                @if (ViewBag.page < ViewBag.pages)
                                {
                                    <li><a href=@Url.Action("List",new { id = type,page = ViewBag.page + 1 })>&raquo;</a></li>
                                }



                            </ul>
                        </div>
                        <!-- /.pagetions -->
                        <!-- .Showing -->
                        <div class="col-xs-12 col-sm-6 col-md-6 text-right">
                            
                        </div>
                        <!-- /.Showing -->
                    </div>
                </div>
            </div>

        </div>
    </div>
</section>